<div class="eui-layout eui-panel" data-options="fit:true">
	<div data-options="region:'west',width:'40%',border:false" style="padding:8px">
		<table class="eui-datagrid" style="height:100%" id="unauthgrid"
			data-options="idField:'id',
				striped:true,
				nowrap:true,
				fitColumns:true,scrollbarSize :0,
				url:'${path}/eframe/org/organization/org!getUnauthList.action?orgid=${orgid}',
				method:'post',
				onLoadError:showErrorMsg,
				autoRowHeight:false">
			<thead>
				<tr>
					<th data-options="field:'id',checkbox:true"></th>
					<th data-options="field:'rolename',halign:'center',align:'left',width:100">未授权角色</th>
				</tr>
			</thead>
		</table>
	</div>
	<div data-options="region:'center',border:false" style="text-align:center;">
		<div style="width:100%;text-align:center;position:absolute;top:40%;">
			<a href="javascript:void(0)" class="eui-linkbutton" data-options="iconCls:'icon-redo',onClick:roleauth" id="roleauthbtn">角色授权</a></br></br>
			<a href="javascript:void(0)" class="eui-linkbutton" data-options="iconCls:'icon-undo',onClick:cancelauth" id="cancelauthbtn">取消授权</a>
		</div>
	</div>
	<div data-options="region:'east',width:'40%',border:false" style="padding:8px">
		<table class="eui-datagrid" style="height:100%" id="authgrid"
			data-options="idField:'id',
				striped:true,
				nowrap:true,
				fitColumns:true,scrollbarSize :0,
				url:'${path}/eframe/org/organization/org!getAuthList.action?orgid=${orgid}',
				method:'post',
				onLoadError:showErrorMsg,
				autoRowHeight:false">
			<thead>
				<tr>
					<th data-options="field:'id',checkbox:true"></th>
					<th data-options="field:'rolename',halign:'center',align:'left',width:100">已授权角色</th>
				</tr>
			</thead>
		</table>
	</div>
</div>
<script>

	function roleauth(){
		var selections = $("#unauthgrid").datagrid("getSelections");
		if(selections.length) {
			$("#roleauthbtn").linkbutton("disable");
			var ids = new List();
			new List(selections).each(function(org){
				ids.add(org.id);
			});
			eui.ajax({
				url:'${path}/eframe/org/organization/org!saveRole.action',
				data:{addRoleIds: ids.toString(), orgid: '${orgid}'},
				success:function() {
					$("#unauthgrid").datagrid("reload");
					$("#authgrid").datagrid("reload");
					$("#roleauthbtn").linkbutton("enable");
				}
			});
		}
	}
	function cancelauth(){
		var selections = $("#authgrid").datagrid("getSelections");
		if(selections.length) {
			$("#cancelauthbtn").linkbutton("disable");
			var ids = new List();
			new List(selections).each(function(org){
				ids.add(org.id);
			});
			eui.ajax({
				url:'${path}/eframe/org/organization/org!saveRole.action',
				data:{delRoleIds: ids.toString(), orgid: '${orgid}'},
				success:function() {
					$("#authgrid").datagrid("reload");
					$("#unauthgrid").datagrid("reload");
					$("#cancelauthbtn").linkbutton("enable");
				}
			});
		}
	};
</script>